package cn.iocoder.yudao.module.peizhen.controller.admin.paitent;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module.peizhen.controller.admin.paitent.vo.*;
import cn.iocoder.yudao.module.peizhen.dal.dataobject.paitent.PaitentDO;
import cn.iocoder.yudao.module.peizhen.service.paitent.PaitentService;

@Tag(name = "管理后台 - 用户的陪诊病人")
@RestController
@RequestMapping("/peizhen/paitent")
@Validated
public class PaitentController {

    @Resource
    private PaitentService paitentService;






    @GetMapping("/get")
    @Operation(summary = "获得用户的陪诊病人")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('peizhen:paitent:query')")
    public CommonResult<PaitentRespVO> getPaitent(@RequestParam("id") Long id) {
        PaitentDO paitent = paitentService.getPaitent(id);
        return success(BeanUtils.toBean(paitent, PaitentRespVO.class));
    }

    @GetMapping("/page")
    @Operation(summary = "获得用户的陪诊病人分页")
    @PreAuthorize("@ss.hasPermission('peizhen:paitent:query')")
    public CommonResult<PageResult<PaitentRespVO>> getPaitentPage(@Valid PaitentPageReqVO pageReqVO) {
        PageResult<PaitentDO> pageResult = paitentService.getPaitentPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, PaitentRespVO.class));
    }


}